package com.ks.template.controller;


import com.ks.core.base._ControllerBase;
import com.ks.core.core.Result;
import com.ks.core.util.StringUtil;
import com.ks.template.controller.dto.TemplateFrameRequest;
import com.ks.template.service.ITemplateFrameService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 * 模板模块-小程序模板信息表 前端控制器
 * </p>
 *
 * @author kingdee123
 * @since 2020-12-09
 */
@RestController
@RequestMapping("/templateFrame")
@Api(value = "应用端模块",description = "应用端模块")
public class TemplateFrameController extends _ControllerBase {

    @Autowired
    private  ITemplateFrameService templateFrameService;

    @GetMapping("/index")
    @ApiOperation(value = "小程序首页模板接口",notes = "小程序首页模板接口")
    public Object HomeIndex (@RequestParam String appid,@RequestParam Integer key,@RequestParam Integer secret){
        Map<String,Object> resultMap =templateFrameService.getHomeIndex(appid,key,secret);
        return Result.success(resultMap);
    }


    @PostMapping("/addTenantModel")
    @ApiOperation(value = "租户模板添加接口", notes = "租户模板添加接口")
    public Object addTenantModel(@RequestBody TemplateFrameRequest templateFrameRequest) {
        int resultMap = templateFrameService.addTenantModel(getContext(), templateFrameRequest);
        return Result.success(resultMap);
    }

    @PostMapping("/deleteTenantModel")
    @ApiOperation(value = "租户模板删除接口", notes = "租户模板删除接口")
    public Object deleteTenantModel(@RequestBody TemplateFrameRequest templateFrameRequest) {
        int resultMap = templateFrameService.deleteTenantModel(getContext(), templateFrameRequest);
        return Result.success(resultMap);
    }

    @PostMapping("/TenantEnableTemplate")
    @ApiOperation(value = "租户启用小程序模板",notes = "租户启用小程序模板")
    public Object TenantEnableTemplate(@RequestBody TemplateFrameRequest request){
        int i = templateFrameService.TenantEnableTemplate(getContext(), request.getId());
        return Result.success(i);
    }


}

